3.6.25 \(\int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx\) [525]

3.6.25.1 Optimal result
3.6.25.2 Mathematica [A] (verified)
3.6.25.3 Rubi [A] (verified)
3.6.25.4 Maple [A] (verified)
3.6.25.5 Fricas [A] (verification not implemented)
3.6.25.6 Sympy [F]
3.6.25.7 Maxima [A] (verification not implemented)
3.6.25.8 Giac [B] (verification not implemented)
3.6.25.9 Mupad [B] (verification not implemented)

3.6.25.1 Optimal result

Integrand size = 21, antiderivative size = 99 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {\left (4 a^2-b^2\right ) \text {arctanh}(\sin (c+d x))}{8 d}+\frac {5 a b \sec ^3(c+d x)}{12 d}+\frac {\left (4 a^2-b^2\right ) \sec (c+d x) \tan (c+d x)}{8 d}+\frac {b \sec ^3(c+d x) (a+b \tan (c+d x))}{4 d} \]

output
1/8*(4*a^2-b^2)*arctanh(sin(d*x+c))/d+5/12*a*b*sec(d*x+c)^3/d+1/8*(4*a^2-b 
^2)*sec(d*x+c)*tan(d*x+c)/d+1/4*b*sec(d*x+c)^3*(a+b*tan(d*x+c))/d
 
3.6.25.2 Mathematica [A] (verified)

Time = 0.06 (sec) , antiderivative size = 120, normalized size of antiderivative = 1.21 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {a^2 \text {arctanh}(\sin (c+d x))}{2 d}-\frac {b^2 \text {arctanh}(\sin (c+d x))}{8 d}+\frac {2 a b \sec ^3(c+d x)}{3 d}+\frac {a^2 \sec (c+d x) \tan (c+d x)}{2 d}-\frac {b^2 \sec (c+d x) \tan (c+d x)}{8 d}+\frac {b^2 \sec ^3(c+d x) \tan (c+d x)}{4 d} \]

input
Integrate[Sec[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]
 
output
(a^2*ArcTanh[Sin[c + d*x]])/(2*d) - (b^2*ArcTanh[Sin[c + d*x]])/(8*d) + (2 
*a*b*Sec[c + d*x]^3)/(3*d) + (a^2*Sec[c + d*x]*Tan[c + d*x])/(2*d) - (b^2* 
Sec[c + d*x]*Tan[c + d*x])/(8*d) + (b^2*Sec[c + d*x]^3*Tan[c + d*x])/(4*d)
 
3.6.25.3 Rubi [A] (verified)

Time = 0.40 (sec) , antiderivative size = 101, normalized size of antiderivative = 1.02, number of steps used = 11, number of rules used = 10, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.476, Rules used = {3042, 3991, 27, 3042, 3086, 15, 4159, 298, 215, 219}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \sec (c+d x)^3 (a+b \tan (c+d x))^2dx\)

\(\Big \downarrow \) 3991

\(\displaystyle \int \sec ^3(c+d x) \left (a^2+b^2 \tan ^2(c+d x)\right )dx+\int 2 a b \sec ^3(c+d x) \tan (c+d x)dx\)

\(\Big \downarrow \) 27

\(\displaystyle \int \sec ^3(c+d x) \left (a^2+b^2 \tan ^2(c+d x)\right )dx+2 a b \int \sec ^3(c+d x) \tan (c+d x)dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \sec (c+d x)^3 \left (a^2+b^2 \tan (c+d x)^2\right )dx+2 a b \int \sec (c+d x)^3 \tan (c+d x)dx\)

\(\Big \downarrow \) 3086

\(\displaystyle \int \sec (c+d x)^3 \left (a^2+b^2 \tan (c+d x)^2\right )dx+\frac {2 a b \int \sec ^2(c+d x)d\sec (c+d x)}{d}\)

\(\Big \downarrow \) 15

\(\displaystyle \int \sec (c+d x)^3 \left (a^2+b^2 \tan (c+d x)^2\right )dx+\frac {2 a b \sec ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 4159

\(\displaystyle \frac {\int \frac {a^2-\left (a^2-b^2\right ) \sin ^2(c+d x)}{\left (1-\sin ^2(c+d x)\right )^3}d\sin (c+d x)}{d}+\frac {2 a b \sec ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 298

\(\displaystyle \frac {\frac {1}{4} \left (4 a^2-b^2\right ) \int \frac {1}{\left (1-\sin ^2(c+d x)\right )^2}d\sin (c+d x)+\frac {b^2 \sin (c+d x)}{4 \left (1-\sin ^2(c+d x)\right )^2}}{d}+\frac {2 a b \sec ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 215

\(\displaystyle \frac {\frac {1}{4} \left (4 a^2-b^2\right ) \left (\frac {1}{2} \int \frac {1}{1-\sin ^2(c+d x)}d\sin (c+d x)+\frac {\sin (c+d x)}{2 \left (1-\sin ^2(c+d x)\right )}\right )+\frac {b^2 \sin (c+d x)}{4 \left (1-\sin ^2(c+d x)\right )^2}}{d}+\frac {2 a b \sec ^3(c+d x)}{3 d}\)

\(\Big \downarrow \) 219

\(\displaystyle \frac {\frac {1}{4} \left (4 a^2-b^2\right ) \left (\frac {1}{2} \text {arctanh}(\sin (c+d x))+\frac {\sin (c+d x)}{2 \left (1-\sin ^2(c+d x)\right )}\right )+\frac {b^2 \sin (c+d x)}{4 \left (1-\sin ^2(c+d x)\right )^2}}{d}+\frac {2 a b \sec ^3(c+d x)}{3 d}\)

input
Int[Sec[c + d*x]^3*(a + b*Tan[c + d*x])^2,x]
 
output
(2*a*b*Sec[c + d*x]^3)/(3*d) + ((b^2*Sin[c + d*x])/(4*(1 - Sin[c + d*x]^2) 
^2) + ((4*a^2 - b^2)*(ArcTanh[Sin[c + d*x]]/2 + Sin[c + d*x]/(2*(1 - Sin[c 
 + d*x]^2))))/4)/d
 

3.6.25.3.1 Defintions of rubi rules used

rule 15
Int[(a_.)*(x_)^(m_.), x_Symbol] :> Simp[a*(x^(m + 1)/(m + 1)), x] /; FreeQ[ 
{a, m}, x] && NeQ[m, -1]
 

rule 27
Int[(a_)*(Fx_), x_Symbol] :> Simp[a   Int[Fx, x], x] /; FreeQ[a, x] &&  !Ma 
tchQ[Fx, (b_)*(Gx_) /; FreeQ[b, x]]
 

rule 215
Int[((a_) + (b_.)*(x_)^2)^(p_), x_Symbol] :> Simp[(-x)*((a + b*x^2)^(p + 1) 
/(2*a*(p + 1))), x] + Simp[(2*p + 3)/(2*a*(p + 1))   Int[(a + b*x^2)^(p + 1 
), x], x] /; FreeQ[{a, b}, x] && LtQ[p, -1] && (IntegerQ[4*p] || IntegerQ[6 
*p])
 

rule 219
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))* 
ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x] /; FreeQ[{a, b}, x] && NegQ[a/b] && (Gt 
Q[a, 0] || LtQ[b, 0])
 

rule 298
Int[((a_) + (b_.)*(x_)^2)^(p_)*((c_) + (d_.)*(x_)^2), x_Symbol] :> Simp[(-( 
b*c - a*d))*x*((a + b*x^2)^(p + 1)/(2*a*b*(p + 1))), x] - Simp[(a*d - b*c*( 
2*p + 3))/(2*a*b*(p + 1))   Int[(a + b*x^2)^(p + 1), x], x] /; FreeQ[{a, b, 
 c, d, p}, x] && NeQ[b*c - a*d, 0] && (LtQ[p, -1] || ILtQ[1/2 + p, 0])
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3086
Int[((a_.)*sec[(e_.) + (f_.)*(x_)])^(m_.)*((b_.)*tan[(e_.) + (f_.)*(x_)])^( 
n_.), x_Symbol] :> Simp[a/f   Subst[Int[(a*x)^(m - 1)*(-1 + x^2)^((n - 1)/2 
), x], x, Sec[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2 
] &&  !(IntegerQ[m/2] && LtQ[0, m, n + 1])
 

rule 3991
Int[sec[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(n 
_), x_Symbol] :> Module[{k}, Int[Sec[e + f*x]^m*Sum[Binomial[n, 2*k]*a^(n - 
 2*k)*b^(2*k)*Tan[e + f*x]^(2*k), {k, 0, n/2}], x] + Int[Sec[e + f*x]^m*Tan 
[e + f*x]*Sum[Binomial[n, 2*k + 1]*a^(n - 2*k - 1)*b^(2*k + 1)*Tan[e + f*x] 
^(2*k), {k, 0, (n - 1)/2}], x]] /; FreeQ[{a, b, e, f}, x] && NeQ[a^2 + b^2, 
 0] && IntegerQ[(m - 1)/2] && IGtQ[n, 0]
 

rule 4159
Int[sec[(e_.) + (f_.)*(x_)]^(m_.)*((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)]^(n_ 
))^(p_.), x_Symbol] :> With[{ff = FreeFactors[Sin[e + f*x], x]}, Simp[ff/f 
  Subst[Int[ExpandToSum[b*(ff*x)^n + a*(1 - ff^2*x^2)^(n/2), x]^p/(1 - ff^2 
*x^2)^((m + n*p + 1)/2), x], x, Sin[e + f*x]/ff], x]] /; FreeQ[{a, b, e, f} 
, x] && IntegerQ[(m - 1)/2] && IntegerQ[n/2] && IntegerQ[p]
 
3.6.25.4 Maple [A] (verified)

Time = 4.72 (sec) , antiderivative size = 118, normalized size of antiderivative = 1.19

method result size
derivativedivides \(\frac {a^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+\frac {2 a b}{3 \cos \left (d x +c \right )^{3}}+b^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{4 \cos \left (d x +c \right )^{4}}+\frac {\sin ^{3}\left (d x +c \right )}{8 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{8}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{8}\right )}{d}\) \(118\)
default \(\frac {a^{2} \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+\frac {2 a b}{3 \cos \left (d x +c \right )^{3}}+b^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{4 \cos \left (d x +c \right )^{4}}+\frac {\sin ^{3}\left (d x +c \right )}{8 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{8}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{8}\right )}{d}\) \(118\)
risch \(-\frac {i {\mathrm e}^{i \left (d x +c \right )} \left (12 a^{2} {\mathrm e}^{6 i \left (d x +c \right )}-3 b^{2} {\mathrm e}^{6 i \left (d x +c \right )}+12 a^{2} {\mathrm e}^{4 i \left (d x +c \right )}+21 b^{2} {\mathrm e}^{4 i \left (d x +c \right )}+64 i a b \,{\mathrm e}^{4 i \left (d x +c \right )}-12 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-21 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+64 i a b \,{\mathrm e}^{2 i \left (d x +c \right )}-12 a^{2}+3 b^{2}\right )}{12 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{4}}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{2 d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2}}{8 d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{2 d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2}}{8 d}\) \(255\)

input
int(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x,method=_RETURNVERBOSE)
 
output
1/d*(a^2*(1/2*sec(d*x+c)*tan(d*x+c)+1/2*ln(sec(d*x+c)+tan(d*x+c)))+2/3*a*b 
/cos(d*x+c)^3+b^2*(1/4*sin(d*x+c)^3/cos(d*x+c)^4+1/8*sin(d*x+c)^3/cos(d*x+ 
c)^2+1/8*sin(d*x+c)-1/8*ln(sec(d*x+c)+tan(d*x+c))))
 
3.6.25.5 Fricas [A] (verification not implemented)

Time = 0.25 (sec) , antiderivative size = 120, normalized size of antiderivative = 1.21 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {3 \, {\left (4 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{4} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (4 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{4} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 32 \, a b \cos \left (d x + c\right ) + 6 \, {\left ({\left (4 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} + 2 \, b^{2}\right )} \sin \left (d x + c\right )}{48 \, d \cos \left (d x + c\right )^{4}} \]

input
integrate(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="fricas")
 
output
1/48*(3*(4*a^2 - b^2)*cos(d*x + c)^4*log(sin(d*x + c) + 1) - 3*(4*a^2 - b^ 
2)*cos(d*x + c)^4*log(-sin(d*x + c) + 1) + 32*a*b*cos(d*x + c) + 6*((4*a^2 
 - b^2)*cos(d*x + c)^2 + 2*b^2)*sin(d*x + c))/(d*cos(d*x + c)^4)
 
3.6.25.6 Sympy [F]

\[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\int \left (a + b \tan {\left (c + d x \right )}\right )^{2} \sec ^{3}{\left (c + d x \right )}\, dx \]

input
integrate(sec(d*x+c)**3*(a+b*tan(d*x+c))**2,x)
 
output
Integral((a + b*tan(c + d*x))**2*sec(c + d*x)**3, x)
 
3.6.25.7 Maxima [A] (verification not implemented)

Time = 0.21 (sec) , antiderivative size = 129, normalized size of antiderivative = 1.30 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {3 \, b^{2} {\left (\frac {2 \, {\left (\sin \left (d x + c\right )^{3} + \sin \left (d x + c\right )\right )}}{\sin \left (d x + c\right )^{4} - 2 \, \sin \left (d x + c\right )^{2} + 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - 12 \, a^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + \frac {32 \, a b}{\cos \left (d x + c\right )^{3}}}{48 \, d} \]

input
integrate(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="maxima")
 
output
1/48*(3*b^2*(2*(sin(d*x + c)^3 + sin(d*x + c))/(sin(d*x + c)^4 - 2*sin(d*x 
 + c)^2 + 1) - log(sin(d*x + c) + 1) + log(sin(d*x + c) - 1)) - 12*a^2*(2* 
sin(d*x + c)/(sin(d*x + c)^2 - 1) - log(sin(d*x + c) + 1) + log(sin(d*x + 
c) - 1)) + 32*a*b/cos(d*x + c)^3)/d
 
3.6.25.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 249 vs. \(2 (91) = 182\).

Time = 0.51 (sec) , antiderivative size = 249, normalized size of antiderivative = 2.52 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {3 \, {\left (4 \, a^{2} - b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 3 \, {\left (4 \, a^{2} - b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + \frac {2 \, {\left (12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{7} + 3 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{7} - 48 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{6} - 12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 21 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 48 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{4} - 12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 21 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 16 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 12 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 16 \, a b\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{4}}}{24 \, d} \]

input
integrate(sec(d*x+c)^3*(a+b*tan(d*x+c))^2,x, algorithm="giac")
 
output
1/24*(3*(4*a^2 - b^2)*log(abs(tan(1/2*d*x + 1/2*c) + 1)) - 3*(4*a^2 - b^2) 
*log(abs(tan(1/2*d*x + 1/2*c) - 1)) + 2*(12*a^2*tan(1/2*d*x + 1/2*c)^7 + 3 
*b^2*tan(1/2*d*x + 1/2*c)^7 - 48*a*b*tan(1/2*d*x + 1/2*c)^6 - 12*a^2*tan(1 
/2*d*x + 1/2*c)^5 + 21*b^2*tan(1/2*d*x + 1/2*c)^5 + 48*a*b*tan(1/2*d*x + 1 
/2*c)^4 - 12*a^2*tan(1/2*d*x + 1/2*c)^3 + 21*b^2*tan(1/2*d*x + 1/2*c)^3 - 
16*a*b*tan(1/2*d*x + 1/2*c)^2 + 12*a^2*tan(1/2*d*x + 1/2*c) + 3*b^2*tan(1/ 
2*d*x + 1/2*c) + 16*a*b)/(tan(1/2*d*x + 1/2*c)^2 - 1)^4)/d
 
3.6.25.9 Mupad [B] (verification not implemented)

Time = 7.25 (sec) , antiderivative size = 216, normalized size of antiderivative = 2.18 \[ \int \sec ^3(c+d x) (a+b \tan (c+d x))^2 \, dx=\frac {\left (a^2+\frac {b^2}{4}\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^7-4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+\left (\frac {7\,b^2}{4}-a^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5+4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4+\left (\frac {7\,b^2}{4}-a^2\right )\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-\frac {4\,a\,b\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2}{3}+\left (a^2+\frac {b^2}{4}\right )\,\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )+\frac {4\,a\,b}{3}}{d\,\left ({\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^8-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^6+6\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4-4\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2+1\right )}+\frac {\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )\,\left (a^2-\frac {b^2}{4}\right )}{d} \]

input
int((a + b*tan(c + d*x))^2/cos(c + d*x)^3,x)
 
output
((4*a*b)/3 + tan(c/2 + (d*x)/2)*(a^2 + b^2/4) + tan(c/2 + (d*x)/2)^7*(a^2 
+ b^2/4) - tan(c/2 + (d*x)/2)^3*(a^2 - (7*b^2)/4) - tan(c/2 + (d*x)/2)^5*( 
a^2 - (7*b^2)/4) - (4*a*b*tan(c/2 + (d*x)/2)^2)/3 + 4*a*b*tan(c/2 + (d*x)/ 
2)^4 - 4*a*b*tan(c/2 + (d*x)/2)^6)/(d*(6*tan(c/2 + (d*x)/2)^4 - 4*tan(c/2 
+ (d*x)/2)^2 - 4*tan(c/2 + (d*x)/2)^6 + tan(c/2 + (d*x)/2)^8 + 1)) + (atan 
h(tan(c/2 + (d*x)/2))*(a^2 - b^2/4))/d